﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using XNA.Common.Objects;

namespace XNA.Common
{
	public class Camera
	{
		#region CONSTRUCTION

		public Camera (Actor focus = null, Vector2 position = default(Vector2), Vector2 target = default(Vector2))
		{
			Focus = focus;
			Position = position;
			Target = target;
		}
		
		#endregion

		#region PROPERTIES

		public Actor Focus
		{
			get;
			set;
		}

		public Vector2 Position
		{
			get;
			set;
		}

		public Vector2 Target
		{
			get;
			set;
		}
		
		#endregion

		#region METHODS (PUBLIC)

		public Matrix CalculateViewMatrix ()
		{
			var camPos = new Vector3 (Focus.Position.X, Focus.Position.Y + Focus.Height + Position.Y, Focus.Position.Z + Position.X);
			return Matrix.CreateLookAt (
				//new Vector3 (0, Focus.Position.Y + Focus.Height + Position.Y, -Position.X), 
				//new Vector3 (0, Focus.Position.Y + Focus.Height + Target.Y, Target.X), 
				camPos,
				Focus.Rotation.Forward + camPos,
				new Vector3 (0, 1, 0));
		}

		#endregion
	}
}
